package com.example.lib_base.mvvm

import android.os.Bundle
import android.view.LayoutInflater
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import java.lang.reflect.ParameterizedType

abstract class BaseViewActivity<VDB : ViewDataBinding> : AppCompatActivity() {
    private val type by lazy {
        (javaClass.genericSuperclass as ParameterizedType).actualTypeArguments
    }
     val binding by lazy {
        val clazz = type[0] as Class<VDB>
        clazz.getMethod("inflate", LayoutInflater::class.java)
            .invoke(null, layoutInflater) as VDB
    }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(binding.root)
        initView()
        initData()
    }

    abstract fun initView()
    abstract fun initData()

}